package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.Autofill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {


    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from sky_take_out.dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

/*插入菜品*/

    @Autofill(value = OperationType.INSERT)
    void add(Dish dish);

    Page<DishVO> select(DishPageQueryDTO dishPageQueryDTO);

@Select("select * from sky_take_out.dish where id=#{id}")
    Dish getById(Long id);
/*
@Delete("delete from sky_take_out.dish where id=#{id}")
    void delete(Long id);
@Delete("delete from  sky_take_out.dish_flavor where dish_id=#{dishId}")
    void deleteByDishID(Long dishId);
*/

    void deletes(List<Long>ids);


    @Autofill(value = OperationType.UPDATE)
    void update(Dish dish);

    void status(Dish dish);
@Select("select * from sky_take_out.dish_flavor")
    void listwithflavor(Dish dish);

    List<Dish> list(Dish dish);


    //@Select("select * from sky_take_out.dish_flavor where id=#{id}")

    @Select("select a.* from sky_take_out.dish a left join sky_take_out.setmeal_dish b on a.id = b.dish_id where b.setmeal_id = #{setmealId}")
    List<Dish> getBySetmealId(Long setmealId);

Integer countByMap(Map map);

}
